import java.util.Scanner;

public class Test_8_19 {

    //力扣：387. 字符串中的第一个唯一字符
    public int firstUniqChar(String s) {
        int ret = -1;
        int[] alphabet = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            alphabet[ch-'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(alphabet[ch-'a'] == 1) {
                ret = i;
                break;
            }
        }
        return ret;
    }

    //力扣：HJ1 字符串最后一个单词的长度
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        int index = str.lastIndexOf(' ');
        System.out.println(str.length() - 1 - index);
    }


    //125. 力扣：验证回文串
    private boolean isLegal(char ch) {
        if(ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9') {
            return true;
        } else {
            return false;
        }
    }
    public boolean isPalindrome(String s) {
        String str = s.toLowerCase();
        int left = 0;
        int right = str.length() - 1;
        while(left < right) {
            while(left < right && !isLegal(str.charAt(left)) ) {
                left++;
            }
            while(left < right && !isLegal(str.charAt(right)) ) {
                right--;
            }
            if(str.charAt(left) != str.charAt(right) ) {
                break;
            }
            left++;
            right--;
        }
        if(left >= right) {
            return true;
        } else {
            return false;
        }
    }
}
